package com.yuneec.droneservice.command;

import com.yuneec.droneservice.request.IResponse;

import java.nio.charset.Charset;

public class WriteSN extends BaseCommand {
    public WriteSN(String sn) {
        super(MAV_RC_COMMAND.MAV_RC_CMD_WRITE_SN);
        byte[] buf = sn.getBytes(Charset.forName("utf8"));
        data = new byte[buf.length + 1];
        data[0] = (byte) (buf.length & 0xff);
        System.arraycopy(buf, 0, data, 1, buf.length);
    }

    @Override
    public IResponse toResponse(byte[] data, int off, int len) {
        int code = data[off + 1] & 0xff;
        return new IResponse(ids(), code);
    }
}
